;;; omnencap.el -- AucTeX support for omnencap.sty

;; Version: 0

;; This file is not part of Emacs

;; Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
;; Maintainer: Phillip Lord <phillip.lord@newcastle.ac.uk>
;; Website: http://www.russet.org.uk

;; COPYRIGHT NOTICE
;;
;; This program is free software; you can redistribute it and/or modify 
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA. 

;;; Commentary:
;;
;; omnencap.sty is a latex style enabling the documentation of ontologies
;; written in the OWL Manchester Syntax. 
;;
;; This file enables AucTeX to support omnencap.sty, with completion on
;; concept, or property names. 
;;
;; To install this file, place it in a directory in the `TeX-style-path'.
;;


(TeX-add-style-hook
 "omnencap"
 (lambda() 
   (TeX-add-symbols
    '("omnclass" omnencap-namespace omnencap-entity)
    '("omnclassr" omnencap-namespace omnencap-entity)
    )))


(defun omnencap-values()
  (let ((file (file-name-sans-extension (buffer-file-name))))
    (with-temp-buffer
      (insert-file (concat file "_ind.el"))
      (eval-buffer))))

(defun omnencap-namespace(optional)
  (omnencap-values)
  (let ((namespace
         (completing-read "Namespace: " (cdr (assoc 'namespace omnencap-index)))))
    (TeX-argument-insert namespace nil)))

(defun omnencap-entity(optional)
  ;; we have already called values, so it should be current
  (let ((entity
         (completing-read "Entity: " (cdr (assoc 'entity omnencap-index)))))
    (TeX-argument-insert entity nil)))

(defun omnencap-unload()
  (interactive)
  (TeX-unload-style "omnencap"))